import processing.net.*;
import tacTile.net.*;

class Tower
{
  int fingerID;
  float x, y,sizeX,sizeY;
  int rechargeTime, damage;
  boolean isEnabled;
  String type;
  Touches myTouch;
  
  Tower()
  {
   rechargeTime = 10;
   damage = 40;
   isEnabled = false; 
  }
  
  Tower(float xcoor, float ycoor,float sx, float sy, int tempTime, int tempDamage, boolean tempIsEnabled, String t)
  {
   x = xcoor;
   y =  ycoor; 
   sizeX = sx;
   sizeY = sy;
   rechargeTime = tempTime;
   damage = tempDamage;
   isEnabled = tempIsEnabled; 
   type = t;
   fingerID = -1;
   isEnabled = false;
   myTouch = null;
  }
  
  int getRechargeTime()
  {
    return rechargeTime;
  }
  
  int getDamage()
  {
    return damage;
  }
  
  int getFingerID()
  {
   return fingerID; 
  }
  
  boolean getIsEnabled()
  {
    return isEnabled;
  }
  
  void setFingerID(int id)
  {
    fingerID = id; 
  }
  
  void setEnabled(boolean bool)
  {
   isEnabled = bool; 
  }
  
  void setMyTouch(Touches t)
  {
   myTouch = t; 
  }
  
  void update()
  {
     noFill();
     ellipse(x,y,sizeX,sizeY); 
     if(isEnabled)
     {
       float xCoord = myTouch.getXPos() * width;
       float yCoord = height - myTouch.getYPos() * height;
       
       line(x,y,xCoord,yCoord);
       
        //calculate distance from where mouse is to where center of circle is
      dX = x-xCoord;
      //calculations to determine if y distance is positive or negative
      if(yCoord <y)
      {
        dY = y - yCoord;
      }
      else
      {
        dY = yCoord - (y);
      }
      //draw a transparent ellipse where the arrow will be shot
      if(yCoord>y)
      {
        noFill();
        ellipse((x + dX*(((width/2)-x)/x)),((y) - dY*3),50,50);
      }
      else
      {
        noFill();
        ellipse((x + dX*(((width/2)-x)/x)),((y) + dY*3),50,50);
      }
    }
  }
}
